home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / tamueethesis / subequation.sty (.txt) < prev    next >
LaTeX Document  |  1993-07-23  |  8KB  |  180 lines

  1. % This file, equations.sty (August 1988), contains a collection of macros
  2. % to aid in constructing displayed equations in LaTeX.  Written by
  3. %   Charles Karney
  4. %   Plasma Physics Laboratory   Phone:   +1 609 243 2607
  5. %   Princeton University        MFEnet:  Karney@PPC.MFEnet
  6. %   PO Box 451                  ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA
  7. %   Princeton, NJ 08543-0451    Bitnet:  Karney%PPC.MFEnet@ANLVMS.Bitnet
  8. % with some ideas and macros borrowed from John Hobby and Stephen Gildea.
  9. % --------------------USER DOCUMENTATION--------------------
  10. % Use this as a style option, e.g.,
  11. %     \documentstyle[equations]{article}
  12. % These probably don't work in conjunction with the leqno option.
  13. % This implements the following:
  14. % (1) \yesnumber turns on an equation number in an eqnarray* environment
  15. % (just as \nonumber turns it off in an eqnarray environment).  E.g.,
  16. %     \begin{eqnarray*}
  17. %        a &=& b \\
  18. %          & & + c \\
  19. %          & & + d \\
  20. %          & & + e \\
  21. %          & & + f \\
  22. %          & & + g \yesnumber
  23. %     \end{eqnarray*}
  24. % (2) The eqalign environment is just like Plain TeX's \eqalign.  E.g.,
  25. %     \begin{equation}
  26. %           \begin{eqalign}
  27. %              a &= b, \\
  28. %              c &= d.
  29. %           \end{eqalign}
  30. %     \end{equation}
  31. % Note that \begin{equation} \end{equation} or equivalent is needed.
  32. % (3) The eqalignno environment is just like Plain TeX's \eqalignno.  E.g.,
  33. %     \begin{eqalignno}
  34. %        a &= b, \label{foo}\\
  35. %        c &= d. \label{bar}
  36. %     \end{eqalignno}
  37. % Note the absence of \begin{equation} \end{equation}.  \nonumber can be used
  38. % to suppress the equation number.  eqalignno* is the same except that the
  39. % equation numbers are suppressed (unless a \yesnumber appears).
  40. % (4) The eqaligntwo environment is a two-equation per line equivalent of
  41. % eqalignno.  E.g.,
  42. %     \begin{eqaligntwo}
  43. %        a &= b, & x &= y, \label{foo} \\
  44. %        c &= d, & z &= w. \label{bar}
  45. %     \end{eqaligntwo}
  46. % eqaligntwo* is defined similarly.
  47. % (5) The cases environment is just like Plain TeX's \cases.  E.g.,
  48. %     \begin{equation}
  49. %        u(x) =
  50. %           \begin{cases}
  51. %             0, & for $x < 0$,
  52. %             1, & for $x \ge 0$.
  53. %           \end{cases}
  54. %     \end{equation}
  55. % Note the first column is treated as math, the second column as text.
  56. % (6) I've borrowed John Hobby's modifications to the eqnarray environment
  57. % (to fix up the spacing around the operator), and to the \big, \bigg, etc.
  58. % operators (to make them scale with the point size).
  59. % (7) I've borrowed Stephen Gildea's subequations environment, and fixed it
  60. % so that it ignores spaces after the environment and so that you can refer
  61. % both to the overall set of equations and to individual subequations.  E.g.,
  62. %     \begin{subequations} \label{foo}
  63. %       \begin{eqalignno}
  64. %          a &= b, \label{foo-a} \\
  65. %          c &= d, \label{foo-b}
  66. %       \end{eqalignno}
  67. %       text text text text ...
  68. %       \begin{equation}
  69. %          e = f. \label{foo-c}
  70. %       \end{equation}
  71. %     \end{subequations}
  72. % Now \ref{foo}, \ref{foo-a}, \ref{foo-b}, \ref{foo-c}, produce 1, 1a, 1b,
  73. % 1c.
  74. % --------------------END OF USER DOCUMENTATION--------------------
  75. % Fix up eqnarray* so that \yesnumber and \nonumber do the obvious things 
  76. \newif\if@defeqnsw \@defeqnswtrue
  77. % This is John Hobby's (hobby@research.att.com) version to fix up the spacing.
  78. \def\eqnarray{\stepcounter{equation}\let\@currentlabel=\theequation
  79. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  80. %\global\@eqnswtrue % It seems redundant here. Deleted by Ken Chiang 4-3-90.
  81. \tabskip\@centering\let\\=\@eqncr
  82. $$\halign to \displaywidth\bgroup\hfil\global\@eqcnt\z@
  83.   $\displaystyle\tabskip\z@{##}$&\global\@eqcnt\@ne 
  84.   \hfil$\displaystyle{{}##{}}$\hfil
  85.   &\global\@eqcnt\tw@ $\displaystyle{##}$\hfil 
  86.   \tabskip\@centering&\llap{##}\tabskip\z@\cr}
  87. \def\yesnumber{\global\@eqnswtrue}
  88. %\def\nonumber{\global\@eqnswfalse}
  89. \def\@@eqncr{\let\@tempa\relax\global\advance\@eqcnt by \@ne
  90.     \ifcase\@eqcnt \def\@tempa{& & & &}\or \def\@tempa{& & &}\or
  91.      \def\@tempa{& &}\or \def\@tempa{&}\else\fi 
  92.      \@tempa \if@eqnsw\@eqnnum\stepcounter{equation}\fi
  93.      \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  94.      \global\@eqcnt\z@\cr}
  95. % Several formulas like \eqalign (to go inside \begin{equation}
  96. % \end{equation} or $$ $$.
  97. \def\@eqnacr{{\ifnum0=`}\fi\@ifstar{\@yeqnacr}{\@yeqnacr}}
  98. \def\@yeqnacr{\@ifnextchar [{\@xeqnacr}{\@xeqnacr[\z@]}}
  99. \def\@xeqnacr[#1]{\ifnum0=`{\fi}\cr \noalign{\vskip\jot\vskip #1\relax}}
  100. \def\eqalign{\null\,\vcenter\bgroup\openup1\jot \m@th \let\\=\@eqnacr
  101. \ialign\bgroup\strut
  102. \hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil\crcr}
  103. \def\endeqalign{\crcr\egroup\egroup\,}
  104. % \cases
  105. \def\cases{\left\{\,\vcenter\bgroup\normalbaselines\m@th \let\\=\@eqnacr
  106.     \ialign\bgroup$##\hfil$&\quad##\hfil\crcr}
  107. \def\endcases{\crcr\egroup\egroup\right.}
  108. % Several formulas like \eqalignno (doesn't need the $$ $$)
  109. \def\eqalignno{\stepcounter{equation}\let\@currentlabel=\theequation
  110. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  111. \let\\=\@eqncr
  112. $$\displ@y \tabskip\@centering \halign to \displaywidth\bgroup
  113.   \global\@eqcnt\@ne\hfil
  114.   $\@lign\displaystyle{##}$\tabskip\z@skip&\global\@eqcnt\tw@
  115.   $\@lign\displaystyle{{}##}$\hfil\tabskip\@centering&
  116.   \llap{\@lign##}\tabskip\z@skip\crcr}
  117. \def\endeqalignno{\@@eqncr\egroup
  118.       \global\advance\c@equation\m@ne$$\global\@ignoretrue}
  119. % Here's the eqalignno* environment:
  120. \@namedef{eqalignno*}{\@defeqnswfalse\eqalignno}
  121. \@namedef{endeqalignno*}{\endeqalignno}
  122. % There is no definition of {eqnarray*}, and the \yesnumber does not work.
  123. % The following two lines are added by Ken Chiang. 4-3-90
  124. \@namedef{eqnarray*}{\@defeqnswfalse\eqnarray}
  125. \@namedef{endeqnarray*}{\endeqnarray}
  126. % Two formulas like \eqalignno (doesn't need the $$ $$)
  127. \def\eqaligntwo{\stepcounter{equation}\let\@currentlabel=\theequation
  128. \if@defeqnsw\global\@eqnswtrue\else\global\@eqnswfalse\fi
  129. \let\\=\@eqncr
  130. $$\displ@y \tabskip\@centering \halign to \displaywidth\bgroup
  131.   \global\@eqcnt\m@ne\hfil
  132.   $\@lign\displaystyle{##}$\tabskip\z@skip&\global\@eqcnt\z@
  133.   $\@lign\displaystyle{{}##}$\hfil\qquad&\global\@eqcnt\@ne
  134.   \hfil$\@lign\displaystyle{##}$&\global\@eqcnt\tw@
  135.   $\@lign\displaystyle{{}##}$\hfil\tabskip\@centering&
  136.   \llap{\@lign##}\tabskip\z@skip\crcr}
  137. \def\endeqaligntwo{\@@eqncr\egroup
  138.       \global\advance\c@equation\m@ne$$\global\@ignoretrue}
  139. \@namedef{eqaligntwo*}{\@defeqnswfalse\eqaligntwo}
  140. \@namedef{endeqaligntwo*}{\endeqaligntwo}
  141. % subequations
  142. %%% File: subeqn.sty
  143. %%% The subequations environment %%%
  144. % Within the subequations environment, the only change is that
  145. % equations are labeled differently.  The number stays the same,
  146. % and lower case letters are appended.  For example, if after doing
  147. % three equations, numbered 1, 2, and 3, you start a subequations
  148. % environmment and do three more equations, they will be numbered
  149. % 4a, 4b, and 4c.  After you end the subequations environment, the
  150. % next equation will be numbered 5.
  151. % Both text and equations can be put inside the subequations environment.
  152. % If you make any improvements, I'd like to hear about them.
  153. % Stephen Gildea
  154. % MIT Earth Resources Lab
  155. % Cambridge, Mass. 02139
  156. % mit-erl!gildea
  157. % gildea@erl.mit.edu
  158. \newtoks\@stequation
  159. \def\subequations{\refstepcounter{equation}%
  160.   \edef\@savedequation{\the\c@equation}%
  161.   \@stequation=\expandafter{\theequation}%   %only want \theequation
  162.   \edef\@savedtheequation{\the\@stequation}% %expanded once
  163.   \edef\oldtheequation{\theequation}%
  164.   \setcounter{equation}{0}%
  165.   \def\theequation{\oldtheequation\alph{equation}}}
  166. \def\endsubequations{%
  167.   \setcounter{equation}{\@savedequation}%
  168.   \@stequation=\expandafter{\@savedtheequation}%
  169.   \edef\theequation{\the\@stequation}%
  170.   \global\@ignoretrue}
  171. % More from John Hobby
  172. % Fix Plain's \bigl, \Bigl, etc. macros so that they try to scale with
  173. % LaTeX size changes.  This uses the fact that \@setsize sets \ht\strutbox
  174. % to be 70% of the normal unstretched baselineskip.
  175. \def\big#1{{\hbox{$\left#1\vcenter to1.428\ht\strutbox{}\right.\n@space$}}}
  176. \def\Big#1{{\hbox{$\left#1\vcenter to2.142\ht\strutbox{}\right.\n@space$}}}
  177. \def\bigg#1{{\hbox{$\left#1\vcenter to2.857\ht\strutbox{}\right.\n@space$}}}
  178. \def\Bigg#1{{\hbox{$\left#1\vcenter to3.571\ht\strutbox{}\right.\n@space$}}}
  179. \endinput
  180.